#include <string.h>
#include <cmath>   
#include <iostream>  //预处理器指令 a PREPROCESSOR directive
using namespace std; //使定义可见   make definitions visible
#include <vector>
#include <array>

/*
  模板类使用 


*/

int main(){

  //模板类 vector
  vector<double>vd(10);//create an array of n doubles

  vector<int> vz; //create a zero-size array of int (不能向其中添加值)

  vector<int> vi(10); //create a zero-size array of int
  vi[0] = 10;
  vi.at(1) = 20; 

  //模板类 array 使用栈(静态内存分配)
  array<double,4> ad ={1.2,2.1,3.43,4.3};

  array<int,5> ai;//create array object of 5 ints
  ai[0] = 100;
  ai.at(1) = 200;

  array<int,5> arr1 = ai;
  cout << "001 数组元素[1]: "<< arr1[1] << endl;

  //包含4个string对象的数组
  const array<string,4> Snames = {"Spring","Summer","Fall","Winter"};
  string str_arr[4] = {"Spring2","Summer2","Fall2","Winter2"};

  cout << "002 字符串array元素[0]: " << Snames[0] << endl;
  cout << "003 字符串数组元素[0]: " << str_arr[0] << endl;

  
  const array<string,4>* Snames_p = &Snames;
  const string * str_arr_p = str_arr;

  cout << "004 字符串array元素 通过指针取值[1]: " << (*Snames_p)[1] << endl;
  cout << "005 字符串数组元素 通过指针取值[1]:" << *(str_arr_p + 1) << endl;
  cout << "006 字符串数组元素 通过指针取值[1]:" << str_arr_p[1] << endl;





}


